<div class="layuimini-container layuimini-page-anim">
	<div class="layuimini-main">

		<fieldset class="table-search-fieldset">
			<legend>搜索信息</legend>
			<div style="margin: 10px 10px 10px 10px">
				<form class="layui-form layui-form-pane"  lay-filter="svrPv" action="">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label ">支付状态</label>
							<div class="layui-input-block">
								<select id="payStatus" name="payStatus" lay-filter="st"
									item_url="/item_lib/pay_status.json">
									<option value="">全部</option>
								</select>
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label ">支付时段</label>
							<div class="layui-input-block" style="width: 100px">
								<select id="selectDate"   name="selectDate" lay-filter="stDate">
									<option value="0">无</option>
									<option value="5">5分钟内</option>
									<option value="10">10分钟内</option>
									<option value="20">20分钟内</option>
									<option value="30">半小时内</option>
									<option value="60">1小时内</option>
									<option value="120">2小时内</option>
									<option value="240">4小时内</option>
									<option value="480">8小时内</option>
									<option value="720">12小时内</option>
								</select>
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label ">支付时间</label>
							<div class="layui-inline" id="dtHa">
								<div class="layui-input-inline" style="width: 125px">
									<input type="text"  autocomplete="off" name="startDate" id="startDate"
										class="layui-input" placeholder="开始时间">
								</div>
								<div class="layui-input-inline" style="width: 125px">
									<input type="text" autocomplete="off"  name="endDate" id="endDate"
										class="layui-input" placeholder="结束时间">
								</div>
							</div>
						</div>
						<div class="layui-inline">
							<button type="submit" class="layui-btn layui-btn-primary"
								lay-submit lay-filter="data-search-btn">
								<i class="layui-icon"></i>搜 索
							</button>
						</div>
					</div>
				</form>
			</div>
		</fieldset>

		<table class="layui-table" id="currentTableId"
			lay-filter="currentTableFilter">
		</table>
	</div>
</div>


<script>
	
    layui.use(['form', 'table','miniPage','element','common','laydate'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
             layarea = layui.layarea,
             laydate=layui.laydate,
            miniPage = layui.miniPage;
            
        //$(this).removeAttr("lay-key");
        
		 //支付时间范围
		  laydate.render({
		    elem: '#dtHa'
		    ,range: ['#startDate', '#endDate']
		    //,range:true
		    ,type: 'datetime'
		    ,format: 'yyyy-MM-dd HH:mm'
		    ,min:-365
		    ,max:1
		    ,done: function(value, date){
		    	if (value!='')
		    		form.val("svrPv", {selectDate:"0"})
     			// layer.msg('你选择的日期是：' + value + '<br><br>获得的对象是' + JSON.stringify(date));
    		}
		  });
		  

         table.render({
        	elem: '#currentTableId',
        	url: '/orders/', 
        	//where:{type:-1},
        	method:'get',
        	toolbar: '<div class="layui-btn-container"></div>', 
        	defaultToolbar: [ 'exports', 'print'], 
			limits: [20, 30, 50, 100], 
			limit: 20,	
			even:true,
			skin: 'row',
			page: true,
              cols: [[
                 {field: 'id', width: 80,  sort: true, title: 'ID'}, 
                {field:'deviceId', minWidth:100,  title: '设备编号'},
                {field:'openId', minWidth:200, sort: false, title: '支付用户', sort: false},
                {field:'payCount', width:100, title: '购买时间',unresize: true},
                {field:'surplusCount', width:100, title: '剩余时间', unresize: true},
                {field:'desc', minWidth:200, title: '订单描述'},
               {field:'fee', minWidth:100, title: '支付金额'},
               {field:'payStatus', minWidth:100, title: '支付状态', templet: function(d){
                		return layui.common.castValueLable("/item_lib/pay_status.json" ,d.payStatus)
      			}, unresize: true},
                {field:'modifyTime', width:150, title: '支付时间', unresize: true},
              ]]
        });
		
  		form.on('select(stDate)', function (data) {
  			//console.log(data);
  			if (data.value!=0)
    	   		form.val("svrPv", {startDate:"",endDate:""})
     	});
    	
      form.on('submit(data-search-btn)', function (data) {
        	//console.log(data.field);
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                },
                 where:  data.field
            	});
            return false;
        });
	  
    	//初始化选择框    
		layui.common.initSelect();

    });
</script>